//
//  SwiperUtils.m
//  HandPaySwiperModule
//
//  Created by marco on 14/12/2.
//  Copyright (c) 2014年 marco. All rights reserved.
//

#import "SwiperUtils.h"

@implementation SwiperUtils

+(int)hexDecode:(const unsigned char*)strHeadPoint  lenght:(int)le outputStrPoint:(char*)str
{
    char data[] ={'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F',};
    
    int i;
    int j = 0;
    unsigned char c;
    
    for(i = 0;i< le; i++)
    {
        c = *strHeadPoint++;
        str[j++] = data[((c>>4)&0x0F)];
        str[j++] = data[c&0x0F];
    }
    str[j] = '\0';
    return j;
}

/*
+(int)hexEncode:(const char*)strHeadPoint length:(const int)len outputStrPoint:(char*)output
{
    char* p = output;
    int j = 0;
    unsigned char hi;
    unsigned char low;
    
    for(int i = 0;i < len;)
    {
        hi = strHeadPoint[i++];
        if( hi>='0' && hi<='9')
            hi -= '0';
        else if(hi>='A' && hi<='F')
        {
            hi -= 'A';
            hi += 10;
        }
        else if(hi>='a' && hi<='f')
        {
            hi -= 'a';
            hi += 10;
        }
        else
            hi = 0;
        
        low = 0;
        if(i < len)
        {
            low = strHeadPoint[i++];
            
            if( low>='0' && low<='9')
                low -= '0';
            else if(low>='A' && low<='F')
            {
                low -= 'A';
                low += 10;
            }
            else if(low>='a' && low<='f')
            {
                low -= 'a';
                low += 10;
            }
        }
        p[j++] = ((hi&0x0F)<<4) | (low&0x0F);
    }
    return j;
}
*/
@end
